{include file="public/top" /}

<body>
<div class="x-body">
    <form class="layui-form">
        <label  class="layui-form-label">
            <span class="x-red">*</span>分类
        </label>
        <div class="layui-input-inline">
            <select id="type" name="type" class="valid">
                <option value="1">Material</option>
                <option value="2">Industry</option>
                <option value="3">Processing</option>
            </select>
        </div>
        <br><br><br>
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>分类名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="username" name="name" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <br><br><br>
        <div>
            <span class="x-red">*</span>分类介绍
            <script type="text/plain" id="editor" class="ueueueue"></script>
            <div class="con-split" style="height: 100px;"></div>
        </div>
        <br>
        <div class="layui-form-item">
            <button type="button"  class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="">提交</button>
        </div>
    </form>
</div>
<script>

    var addurl = '/admin/Application/typeadd';
    //编辑器
    var ue = UE.getEditor('editor');
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //自定义验证规则
        form.verify({
            pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
        });
        //监听提交
        form.on('submit(add)', function(data){
            $.post(addurl, data.field,function(res) {
                var success = JSON.parse(res);
                if(success.code===200){
                    layer.msg(success.msg, {
                        time: 1000, //不自动关闭
                        icon:6,
                        end:function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        }
                    });
                    return false;
                }else {
                    layer.msg(success.msg)
                }


            });

        });
    });

</script>


</body>

</html>